package polimi.sc.expoquest.storage.model;

import java.util.ArrayList;
import java.util.Collection;

/**
 * This class represents a gossip in the application
 * @author Monica Lozano
 */
public class Gossip {

	//----------------
	//ATTRIBUTES
	//----------------
	/**
	 * ID in the database, this id is related to the _id column
	 * of the table, and this is automatically autoincremented
	 */
	private int id;
	/**
	 * The gossip that is being saved/retrieved
	 */
	private String gossip;
	/**
	 * If the gossip has a related picture
	 */
	private String picURI;
	/**
	 * The user that publish the gossip
	 */
	private User user;
	/**
	 * TODO do we really need to maintain this? with the gossip id 
	 * we can always retrieve the related comments
	 * The comments that this gossip has
	 */
	private Collection<GossipComment> comments;
	
	//----------------
	//CONSTRUCTOR
	//----------------
	public Gossip(){}
	
	/**
	 * If the gossip doesnt have any related picture
	 * @param id
	 * @param gossip
	 * @param user
	 */
	public Gossip(int id, String gossip, User user)
	{
		this.id= id;
		this.gossip= gossip;
		this.user= user;
		this.comments = new ArrayList<GossipComment>();
	}
	/**
	 * If the gossi has a related picture
	 * @param id
	 * @param gossip
	 * @param picURI
	 * @param user
	 */
	public Gossip(int id, String gossip,String picURI, User user)
	{
		this.id= id;
		this.gossip= gossip;
		this.user= user;
		this.picURI = picURI;
		comments= null;
	}
	
	/**
	 * Adds a comment to the gossip
	 * @param c
	 */
	public void addComment(GossipComment c)
	{
		if(comments == null)
			this.comments = new ArrayList<GossipComment>();
		this.comments.add(c);
	}
	//-------------------
	//GETTERS AND SETTERS
	//-------------------
	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	/**
	 * @return the gossip
	 */
	public String getGossip() {
		return gossip;
	}
	/**
	 * @param gossip the gossip to set
	 */
	public void setGossip(String gossip) {
		this.gossip = gossip;
	}
	/**
	 * @return the picURI
	 */
	public String getPicURI() {
		return picURI;
	}
	/**
	 * @param picURI the picURI to set
	 */
	public void setPicURI(String picURI) {
		this.picURI = picURI;
	}
	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}
	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}
	/**
	 * @return the comments
	 */
	public Collection<GossipComment> getComments() {
		return comments;
	}
	/**
	 * @param comments the comments to set
	 */
	public void setComments(Collection<GossipComment> comments) {
		this.comments = comments;
	}

	
}
